/**
 * Created by loso on 2017/3/16.
 */
public class _26_RemoveDuplivatesFromSortedArray {
    public static void main(String[] args) {
_26_RemoveDuplivatesFromSortedArray a = new _26_RemoveDuplivatesFromSortedArray();
    }

    public int removeDuplicates(int[] nums) {
        if (nums.length == 0){
            return 0;
        }
        int index = 0;
        for(int i = 0; i<nums.length;i++){
            if(nums[i] == nums[index]){
                nums[index] = nums[i];
            }
            else{
                index++;
                nums[index] = nums[i];
            }
        }
        return index+1;
    }

    public int removeDuplicatesBigBoss(int[] nums) {
        int i = nums.length > 0 ? 1 : 0;
        for (int n : nums)
            if (n > nums[i-1])
                nums[i++] = n;
        return i;
    }

}
